"""
URL configuration for ai_info_server project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/4.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import include, path
from rest_framework import routers
from ai.views import (ArticleKeywordOptionView, ArticleViewSet, ArticleCategoryViewSet, ArticleKeywordViewSet,
                      BlacklistRefreshView, get_profile, create_article_by_analysis,
                      RegisterView, merge_category_view,
                      article_analysis_by_keyword, update_profile, UserKeywordFocusViewSet, UserFocusEventArticleViewSet)
from django.conf import settings
from django.conf.urls.static import static
from rest_framework.documentation import include_docs_urls
from rest_framework_simplejwt.views import (
    TokenRefreshView,
)

from ai_info_server.views import MyObtainTokenPairView, CaptchaAPIView

router = routers.DefaultRouter()
router.register(r'ai-news', ArticleViewSet, 'article')
router.register(r'ai-keywords', ArticleKeywordViewSet, "keywords")
router.register(r'ai-category', ArticleCategoryViewSet, "category")
router.register(r'ai-focus-event', UserKeywordFocusViewSet, 'keywordsFocus')
router.register(r'ai-focus-event-articles', UserFocusEventArticleViewSet, 'focus-event-articles')

# TODO 写个中间件， 用于记录访问信息
# 需要什么格式的日志，需要约定下存储什么信息
urlpatterns = [
    # path("wordcloud-imag/", get_word_cloud_image),
    # path('docs/', include_docs_urls(title='接口文档', schema_url="")),
    path('api/register/', RegisterView.as_view(), name='auth_register'),
    path('api/login/', MyObtainTokenPairView.as_view(), name='login'),
    path('api/logout/', BlacklistRefreshView.as_view(), name="logout"),
    path('api/captcha/', include('captcha.urls')),
    path('api/profile/', get_profile, name='profile'),
    path('api/profile/update/', update_profile, name='update-profile'),
    path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
    path('admin/', admin.site.urls),
    path('api/', include(router.urls)),
    path('api-auth/', include('rest_framework.urls')),
    path('api/keyword/options/', ArticleKeywordOptionView.as_view(), name='keyword_option'),
    path('api/captcha/image-data/', CaptchaAPIView.as_view(), name='captcha_image_data'),
    path('api/analysis/import', create_article_by_analysis, name='analysis'),
    path('api/keyword/article-analysis/', article_analysis_by_keyword, name='article_analysis_by_keyword'),
    path('api/merge-category/', merge_category_view, name='merge_category_view'),
    path('', include('ai.urls')),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
